package simple.common;

import java.util.Date;
import java.util.UUID;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Name;
import org.nutz.lang.Strings;

public abstract class BaseEntity {

    public static final String NEW_ID = "NEW_ID";

    @Name
    protected String id;
    @Column(hump = true)
    private Date createAt;
    @Column(hump = true)
    private Date modifyAt;

    public static String uuid() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    public boolean isNew() {
        if (Strings.isBlank(id)) {
            return true;
        }
        return NEW_ID.equals(this.id);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Date createAt) {
        this.createAt = createAt;
    }

    public Date getModifyAt() {
        return modifyAt;
    }

    public void setModifyAt(Date modifyAt) {
        this.modifyAt = modifyAt;
    }

}
